const express=require('express')
let app=express()
app.listen(3000,()=>{
    console.log('3000ok');
})

// 引入模块
const  mysql=require("mysql");
// 创建连接
let  con=mysql.createConnection({
    host:"localhost",
    port:3306,
    user:"root",
    password:"root",
    database:"user"
})

con.connect()





app.get("/userinfo",(req,res)=>{


    let sql=`select *  from user`
    let sql1=`select *  from user where id=2`


    let p=new  Promise((resolve,reject)=>{
        con.query(sql,(err,results)=>{
            resolve([err,results])
        })
    })


    let p1=new  Promise((resolve,reject)=>{
        con.query(sql1,(err,results)=>{
            resolve([err,results])
        })
    })

    async function getuser(){
        let [err,results]=await p
        console.log([err,results]);

        let [err1,results1]=await p1;
        console.log([err1,results1]);

    }
    getuser()


    res.send("Ok")




})